package com.fingard.dsp.bank.reqrespobj.gateway;

import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;

import com.fingard.constant.Format;
import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RequestBase;
import com.fingard.xml.XmlTextReader;

/**
 * 网关支付请求实体类
 */
public class ReqGateway extends RequestBase {
	public XmlTextReader xmlReader;
	public HashMap<String,String> reqHashMap;
	
	public Date getTimeStart() throws ParseException {
		Date timeStart = Format.DateTime14Format.parse(reqHashMap.get("TimeStart"));
		return timeStart;
	}
	
	public Date getTimeExpire() throws ParseException {
		Date timeExpire = Format.DateTime14Format.parse(reqHashMap.get("TimeExpire"));
		return timeExpire;
	}
	
	/** 获取有效时间 */
	public String getValidTime() throws ParseException {
		long timeOut = (getTimeExpire().getTime() - getTimeStart().getTime())/1000/60;
		return String.valueOf(timeOut);
	}
	
	public ReqGateway(XmlTextReader p_xmlReader, ReqRespHeader p_header){
		reqHeader = p_header;
		xmlReader = p_xmlReader;
	}
	
	public ReqGateway(ReqRespHeader p_header){
		reqHeader = p_header;
	}
	
	public ReqGateway(HashMap<String,String> p_reqHashMap, ReqRespHeader p_header){
		reqHeader = p_header;
		reqHashMap = p_reqHashMap;
	}
}
